define(["jquery", "easy-admin"], function ($, ea) {

    var init = {
        table_elem: '#currentTable',
        table_render_id: 'currentTableRenderId',
        index_url: 'mall.member/index',
        balance_url:'mall.account/index',
        add_url: 'mall.member/add',
        edit_url: 'mall.member/edit',
        delete_url: 'mall.member/delete',
        export_url: 'mall.member/export',
        modify_url: 'mall.member/modify'
    };

    var Controller = {
        index: function () {
            ea.table.render({
                init: init,
                toolbar: ['refresh',
                    [],
                    'export'],
                cols: [[
                    {type: "checkbox"},
                    {field: 'id', width: 80, title: 'ID'},
                    {field: 'openid', minWidth: 120, title: '微信标识'},
                    {field: 'avatarUrl', minWidth: 60, title: '微信头像',search: false, templet: ea.table.image},
                    {field: 'nickName', minWidth: 60, title: '微信昵称'},
                    {field: 'mobile', minWidth: 80, title: '手机号'},
                    {field: 'balance', width: 100, title: '账户余额',search: false, templet: ea.table.price},
                    {field: 'title', width: 100, title: '购买会员卡',search: false},
                    {field: 'status', title: '状态', width: 100, selectList: {0: '禁用', 1: '启用'}, templet: ea.table.switch},
                    {field: 'create_time', minWidth: 80, title: '注册时间', search: 'range'},
                    {field: 'update_time', minWidth: 80, title: '最近更新时间', search: 'range'},
                    {
                        width: 250,
                        title: '操作',
                        templet: ea.table.tool,
                        operat: [
                            [{
                                text: '编辑余额',
                                url: init.edit_url,
                                method: 'open',
                                auth: 'edit',
                                class: 'layui-btn layui-btn-xs layui-btn-success',
                                extend: 'data-full="true"',
                            },
                            {
                                text: '钱包明细',
                                url: init.balance_url,
                                method: 'open',
                                auth: 'balance',
                                class: 'layui-btn layui-btn-xs layui-btn-normal',
                                extend: 'data-full="true"',
                            }],
                            'delete']
                    }
                ]],
            });

            ea.listen();
        },
        add: function () {
            ea.listen();
        },
        edit: function () {
            ea.listen();
        }

    };
    return Controller;
});